/*
 * Style.java
 */

package xq.swing.text;

import java.awt.Color;

/**
 *
 * @author ThorntonRP
 */
public class Style {

	private Style parentStyle;
	private Color foregroundColor;
	private int fontStyle;
	
	public Style() {
		
	}

	public int getFontStyle() {
		return choose(fontStyle, parentStyle.fontStyle);
	}

	public void setFontStyle(int fontStyle) {
		this.fontStyle = fontStyle;
	}

	public Color getForegroundColor() {
		return choose(foregroundColor, parentStyle.foregroundColor);
	}

	public void setForegroundColor(Color foregroundColor) {
		this.foregroundColor = foregroundColor;
	}

	public Style getParentStyle() {
		return parentStyle;
	}

	public void setParentStyle(Style parentStyle) {
		this.parentStyle = parentStyle;
	}
	
	private <T> T choose(T first, T second) {
		return first == null ? second : first;
	}
}
